package com.teamb6.shop.util;

import com.teamb6.shop.domain.Activity;
import com.teamb6.shop.domain.Category;
import com.teamb6.shop.domain.Goods;

import java.util.HashMap;

import java.util.List;
import java.util.Map;

/**
 * 提示信息
 */
public class Msg {
    //100-success,200-fail
    private int code;
    //分页时返回数据的条数
    private Long total;
    //提示信息
    private String msg;
    //数据
    private Map<String,Object> info = new HashMap<>();

    private List<Activity> activities;
    private List<Category> categories;
    private List<Goods> goods;

    public List<Category> getCategories() {
        return categories;
    }

    public void setCategories(List<Category> categories) {
        this.categories = categories;
    }

    public List<Goods> getGoods() {
        return goods;
    }

    public void setGoods(List<Goods> goods) {
        this.goods = goods;
    }

    public Map<String, Object> getInfo() {
        return info;
    }

    public void setInfo(Map<String, Object> info) {
        this.info = info;
    }



    public static Msg success(String msg){
        Msg result = new Msg();
        result.setCode(100);
        result.setMsg(msg);
        return result;
    }

    public static Msg fail(String msg){
        Msg result = new Msg();
        result.setCode(200);
        result.setMsg(msg);
        return result;
    }

    public Msg add(String key,Object value){
        this.getInfo().put(key,value);
        return this;
    }

    public Msg addActivity(Long total,List<Activity> activities){
        this.total = total;
        this.activities = activities;
        return this;
    }



    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public Long getTotal() {
        return total;
    }

    public void setTotal(Long total) {
        this.total = total;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public List<Activity> getActivities() {
        return activities;
    }

    public void setActivities(List<Activity> activities) {
        this.activities = activities;
    }
    public Msg addGoods(Long total, List<Goods> goods){
        this.total = total;
        this.goods = goods;
        return this;
    }
    public Msg addCategory(Long total,List<Category> categories){
        this.total=total;
        this.categories=categories;
        return this;
    }

}
